package net.crazyblock.mobilesafe;

import net.crazyblock.mobilesafe.ui.SettingItemView;
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class SettingActivity extends Activity {
	private SettingItemView siv_1;
	private SharedPreferences sp;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_seting);
		sp = getSharedPreferences("config", MODE_PRIVATE);
		siv_1 = (SettingItemView) findViewById(R.id.siv_1);

		boolean is_siv_1 = sp.getBoolean("siv_1", false);
		siv_1.setCheck(is_siv_1);

		siv_1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Editor editor = sp.edit();
				if (siv_1.isCheck()) {
					siv_1.setCheck(false);
					editor.putBoolean("siv_1", false);
				} else {
					siv_1.setCheck(true);
					editor.putBoolean("siv_1", true);
				}
				editor.commit();
			}
		});

	}
}
